package com.cyx.controller;

import org.springframework.lang.Nullable;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class HelloContorller implements Controller {
    @Nullable
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest,
        HttpServletResponse httpServletResponse) throws Exception {
        //
        ModelAndView mv = new ModelAndView();
        //封装数据，放在ModelAndView中,注意原先放数据都是放在Session之类里，现在直接放Model
        mv.addObject("msg","hello springmvc");
        //封装要跳转的视图 放在ModelAndView中,会根据配置中的前缀后缀自行拼装查找 /WEB-INF/jsp/hello.jsp
        mv.setViewName("hello");
        return mv;
    }
}
